<template>
  <div class="child2">
    <h3>子组件2</h3>
	<h4>Computer: {{ pc }}</h4>
	<h4>toy from child1: {{ toy }}</h4>
  </div>
</template>

<script setup lang="ts" name="Child2">
	import {onUnmounted, ref} from 'vue'
	import emitter from '@/utils/emitter';

	let pc = ref('Lenvo')
	let toy = ref('')
	// emitter bind event
	emitter.on('send-toy', (value:any) => {
		toy.value = value
	})
	onUnmounted(() => {
		emitter.off('send-toy')
	})
</script>

<style scoped>
	.child2{
		margin-top: 50px;
		background-color: orange;
		padding: 10px;
		box-shadow: 0 0 10px black;
		border-radius: 10px;
	}
</style>